﻿using Serilog.Core;
using Serilog.Events;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SSPivot.Common.Serilog
{
    public class IPEnricher : ILogEventEnricher
    {
        public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory)
        {
            if (logEvent.Properties.TryGetValue("IP", out var ipValue))
            {
                var ipProperty = new LogEventProperty("IP", ipValue);
                logEvent.AddPropertyIfAbsent(ipProperty);
            }
        }
    }
}
